<title>企业/组织</title>


<div class="layui-fluid classManager">
    <div class="layui-row">

        <div class="layui-col-md12">

            <div class="layui-card">
                <div class="layui-card-body">
                    <button class="layui-btn layui-btn-sm" data-type="">
                        待认证
                    </button>
                    <hr>
                    <table class="layui-table" id="classEle" lay-filter="test3">
                    </table>
                </div>
            </div>
        </div>

    </div>
</div>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看/审核</a>
    <a class="layui-btn layui-btn-xs" lay-event="renzheng">
        {{# if(d.renzheng == 0){ }}
        <!--已认证-->
        已认证
        {{# } else if (d.renzheng == 1) { }}
        <!--未认证-->
        实名认证
        {{# } }}
    </a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>


<script>
    layui.use(['admin','table'], function () {
        var table = layui.table,
            admin = layui.admin;
        var $ = layui.$; //由于layer弹层依赖jQuery，所以可以直接得到

        table.render({
            elem : '#classEle',
            url:'./json/user/companyUser.js',
            id:'test3',
            page:'true',
            cellMinWidth: 80, //常规单元格最小宽度
            cols : [[
                {type:'checkbox'},
                {field:'uid', title: 'UID', sort: true, width:80},
                {field:'companyname', title : '单位名称', minWidth: 150},
                {field:'checked', title : '资料审核', width : 100, templet : function (d) {
                        if (d.checked == 0) {
                            return '未审核';
                        } else if (d.checked == 1) {
                            return '已审核';
                        }
                    }},
                {field:'regDate', title : '注册日期', sort: true, width: 180},
                {field:'phoneNumber', title : '手机号', width:140},
                {field:'contactName', title : '联系人', width:80},
                {field:'contactNumber', title : '联系人电话', width:140},
                {fixed: 'right', align:'center', toolbar: '#barDemo', minWidth : 210}
            ]]
        });

        //监听工具条
        table.on('tool(test3)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                // layer.msg('ID：' + data.id + ' 的查看操作');

                var _btn = '';

                if (data.checked == 0) {
                    _btn = '<div class="layui-form-item">' +
                        '          <div class="layui-input-block">' +
                        '            <div class="layui-footer">' +
                        '              <button class="layui-btn">通过</button>' +
                        '              <button class="layui-btn layui-btn-danger">拒绝</button>' +
                        '            </div>' +
                        '          </div>' +
                        '        </div>';
                } else {
                    _btn = '<div class="layui-form-item">' +
                        '          <div class="layui-input-block">' +
                        '            <div class="layui-footer">' +
                        '              <button class="layui-btn layui-btn-disabled">已通过</button>' +
                        '              <button class="layui-btn layui-btn-danger">拒绝</button>' +
                        '            </div>' +
                        '          </div>' +
                        '        </div>';
                }

                var _storyPic = '';

                for (var i = 0; i < data.storyPic.length; i++) {
                    _storyPic += '<image src="' + data.storyPic[i] + '"></image>';
                }
                _storyPic = '<div class="layui-form-item"><label class="layui-form-label">公司图片及企业风采</label><div class="layui-input-block">' + _storyPic + '</div></div>';


                layer.open({
                    title: data.nickname
                    ,type: 1
                    //,skin: 'layui-layer-rim'
                    ,shadeClose: true
                    ,area: admin.screen() < 2 ? ['80%', '300px'] : ['700px', '500px']
                    ,content: '<div style="padding: 20px;">' +
                    '<div class="layui-form-item"><label class="layui-form-label">头像</label><div class="layui-input-block"><image src="' + data.portrait + '"></image></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">UID</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.uid + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">用户名</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" readonly value="' + data.companyname + '" class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">注册日期</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.regDate + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">手机号</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.phoneNumber + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">邮箱</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.email + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">联系人</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.contactName + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">联系人电话</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.contactNumber + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">网址</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.website + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">单位属性</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.property + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">行业</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.hangye + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">注册状况</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.zhucezhuangkuang + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">规模</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.guimo + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">地区</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.region + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">地址</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.address + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">简介</label><div class="layui-input-block"> <textarea name="text" readonly class="layui-textarea">' + data.intro + '</textarea></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">品牌故事</label><div class="layui-input-block"> <textarea name="text" readonly class="layui-textarea">' + data.story + '</textarea></div></div>' +
                    _storyPic +
                    _btn +
                    '</div>'
                });

            } else if (obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    obj.del();
                    layer.close(index);
                });
            } else if (obj.event === 'renzheng') {

                var _btn = '';

                if (data.checked == 0) {
                    _btn = '<div class="layui-form-item">' +
                        '          <div class="layui-input-block">' +
                        '            <div class="layui-footer">' +
                        '              <button class="layui-btn">通过认证</button>' +
                        '              <button class="layui-btn layui-btn-danger">拒绝认证</button>' +
                        '            </div>' +
                        '          </div>' +
                        '        </div>';
                } else {
                    _btn = '<div class="layui-form-item">' +
                        '          <div class="layui-input-block">' +
                        '            <div class="layui-footer">' +
                        '              <button class="layui-btn layui-btn-disabled">已通过</button>' +
                        '              <button class="layui-btn layui-btn-danger">拒绝认证</button>' +
                        '            </div>' +
                        '          </div>' +
                        '        </div>';
                }

                layer.open({
                    title: data.nickname
                    ,type: 1
                    //,skin: 'layui-layer-rim'
                    ,shadeClose: true
                    ,area: admin.screen() < 2 ? ['80%', '300px'] : ['700px', '500px']
                    ,content: '<div style="padding: 20px;">' +
                    '<div class="layui-form-item"><label class="layui-form-label">公司名称</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.coName + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">法人</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" value="' + data.corporate + '" readonly class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">法人身份证号</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" readonly value="' + data.corporateId + '" class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">营业执照编号</label><div class="layui-input-block"><input type="text" name="title" lay-verify="title" autocomplete="off" readonly value="' + data.coId + '" class="layui-input"></div></div>' +
                    '<div class="layui-form-item"><label class="layui-form-label">营业执照照片</label><div class="layui-input-block"><image src="' + data.coPic + '"></image></div></div>' +
                    _btn +
                    '</div>'
                });
            }
        });


        var active = {
            addClass: function () {
                layer.prompt({
                    formType: 0,
                    title: '新增分类[' + $('.layui-breadcrumb cite').text() + ']',
                    area: ['200px', '40px'] //自定义文本域宽高
                }, function (value, index, elem) {
                    alert(value); //得到value
                    layer.close(index);
                });
            }
        };

        $('.classManager .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //监听单元格编辑
        table.on('edit(test3)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改为：' + value);
        });
    });
</script>